package lumis.doui.control.strings;

import org.w3c.dom.Node;

import lumis.doui.control.Control;
import lumis.doui.control.ControlContainer;
import lumis.doui.control.IControl;
import lumis.portal.PortalException;
import lumis.util.XmlUtil;

/**
 * Renders javascript on the client side that makes available in an array a list of translated strings.
 * <br/>
 * <br/> 
 * Example use:
 * <xmp>
 * <control:lum_strings id="forumClientStrings">
 * 	<strings>
 * 		<string id="STR_CONFIRM_DELETE"/>
 * 	</strings>
 * </control:lum_strings>
 * </xmp>
 * 
 * xml data available for xsl rendering:
 * <xmp>
 * <control id="forumClientStrings" type="lum_strings">
 * 	<strings escape="true">
 * 		<string id="STR_CONFIRM_DELETE">Are you sure you want to delete this message?</string> 
 * 	</strings>
 * </control>
 * </xmp> 
 * 
 * Doui Control that translate the specified strings and add them to a javascript array identified by the control id.
 * 
 * @since 4.0.5
 * @version $Revision: 6597 $ $Date: 2007-04-26 16:53:01 -0300 (Thu, 26 Apr 2007) $
 */
public class StringsControl extends Control
{
	
	public void init(Node controlDefinitionNode, ControlContainer controlContainer, IControl parentControl) throws PortalException
	{
		super.init(controlDefinitionNode, controlContainer, parentControl);
		Node stringsNode = XmlUtil.selectSingleNode("strings", controlDefinitionNode);
		
		if(stringsNode != null)
			XmlUtil.addNodeAttr(stringsNode, "escape", "true");
	}
}
